home *** CD-ROM | disk | FTP | other *** search
/ PC Format (PL) 2008 December / PC_Format_122008.iso / Dodatki / Dodatki Vista / SpeedTest.gadget / misc.js < prev    next >
Text File  |  2008-03-28  |  3KB  |  100 lines

  1. /* This notice must remain at all times.
  2.  
  3. afgraphst.js
  4. Copyright (c) Absolute Futurity, 2007.  All rights reserved.
  5. http://www.absolutefuturity.com 
  6. sales@absolutefuturity.com
  7. Version 1.0.2
  8.  
  9. READ THIS CAREFULLY!
  10.  
  11. - Absolute Futurity does NOT allow you modify any of the source code in anyway, shape or form!
  12. - Absolute Futurity does NOT allow duplication of any part of this source code!
  13. - Absolute Futurity does NOT allow the use of any parts (background skins, icons, buttons, code, etc...) in any other gadget or product.
  14. - Absolute Futurity does NOT allow any part of this gadget to be used as base for another development start.
  15. - If you want to use any part or function of this gadget, you will need to contact us from our website for written permission first.
  16.  
  17. !!! Many extra features are available for this gadget with interaction with our product "Speed Test Pro" http://speedtestpro.net/SpeedTest.exe !!!
  18.  
  19. */
  20.  
  21. var cpucount = System.Machine.CPUs.count;
  22. var defcolors = new Array('#00ff00','#ff01ff','#0000ff','#ff0000','#01FFFF','#FFFF00','#808080','#FFFFFF','#C0C0FF');
  23. var lunitletter = new Array('m','','K','M','G','T');
  24.  
  25. var timebases = new Array(0,1000,60,60,24);
  26.  
  27. var maxlegendunits = 2;
  28. var vencross = true;
  29. var btimeunits = false;
  30. var tmpfileread = '';
  31. var lbase = 1000000000000000;
  32. var lpower = 0;
  33. var legendunits;
  34. var anodetypes;
  35. var anodetypesshort;
  36. var oCPUs;
  37. var anodemax;
  38. var mGlobalOffset;
  39.  
  40. resettypes();
  41. addextratypes();
  42.  
  43. function gadgetsettingread(gsetting,gdefault){
  44.  if (System.Gadget.Settings.read ('Started') == '1') {
  45.   tmpst = System.Gadget.Settings.read (gsetting);
  46.   return tmpst;
  47.  }
  48.  else {
  49.   return gdefault;
  50.  }
  51. }
  52.  
  53. function resettypes(){
  54.  anodetypes = null;
  55.  anodetypesshort = null;
  56.  legendunits = null;
  57.  oCPUs = null;
  58.  legendunits = new Array('Percent');
  59.  anodetypes = new Array();
  60.  anodetypesshort = new Array();
  61.  oCPUs = new Array();
  62.  for (il = 0; il < cpucount; il++){
  63.   anodetypes.push("CPU Core " + il);
  64.   anodetypesshort.push("CPU" + il);
  65.   oCPUs.push(System.Machine.CPUs.item(il));
  66.  }
  67.  anodetypesshort.push('RAM-U','RAM-F');
  68.  anodetypes.push('RAM Used','RAM Free');
  69.  anodemax = anodetypes.length;
  70. }
  71.  
  72. function addextratypes(){
  73.  var fso = new ActiveXObject("Scripting.FileSystemObject");
  74.  if (fso.FileExists(System.Gadget.path + "/avail.txt")) {
  75.   s = fso.OpenTextFile(System.Gadget.path + "/avail.txt", 1)
  76.   tmpfileread = s.ReadAll();
  77.   s.Close();
  78.   s = null;
  79.   fso = null;
  80.  
  81.   var tmpavail = tmpfileread.replace(/\r/g,"").split('\n');
  82.   for (i=0; i<tmpavail.length-1; i++){
  83.    if (tmpavail[i] != "") {
  84.     tmpinfo = tmpavail[i].split("=");
  85.     anodetypesshort.push(tmpinfo[0]);
  86.     anodetypes.push(tmpinfo[1]);
  87.     tmplegenunits = tmpinfo[2].split(",");
  88.     for (ii=0; ii<=tmplegenunits.length-1; ii++){
  89.      bfound=false;
  90.      for (iii=0; iii<=legendunits.length-1; iii++){
  91.       if (tmplegenunits[ii] == legendunits[iii]) bfound = true;
  92.      }
  93.      if (!bfound) legendunits.push(tmplegenunits[ii]);
  94.     }
  95.    }  
  96.   }
  97.  }
  98.  fso = null;
  99. }
  100.